<?php
/**
 * POSCMS框架文件
 * 二次开发时请勿修改本文件
 * 四川迅睿云软件开发有限公司 www.xunruicms.com
 */

/**
 * 钩子定义配置
 */
defined('BASEPATH') OR exit('No direct script access allowed');

// 加载应用的钩子配置文件
if (is_file(WEBPATH.'config/app_hooks.php')) {
    $app = require WEBPATH.'config/app_hooks.php';
    if ($app) {
        foreach ($app as $dir => $data) {
            if ($data) {
                foreach ($data as $name => $value) {
                    if (isset($hook[$name]) && is_array($value)) {
                        foreach ($value as $val) {
                            $hook[$name][] = $val;
                        }
                    } else {
                        $hook[$name] = $value;
                    }
                }
                unset($name, $value);
            }
        }
        unset($data, $dir);
    }
    unset($app);
}
// 新版插件钩子
if (is_file(CACHEPATH.'config/app_hooks.php')) {
    $app = require CACHEPATH.'config/app_hooks.php';
    if ($app) {
        foreach ($app as $dir => $data) {
            if ($data) {
                foreach ($data as $name => $value) {
                    if (isset($hook[$name]) && is_array($value)) {
                        foreach ($value as $val) {
                            $hook[$name][] = $val;
                        }
                    } else {
                        $hook[$name] = $value;
                    }
                }
                unset($name, $value);
            }
        }
        unset($data, $dir);
    }
    unset($app);
}


// 加载自定义钩子配置文件
if (is_file(WEBPATH.'config/my_hooks.php')) {
    require WEBPATH.'config/my_hooks.php';
}



/*
$hook['钩子名称'][] = array(
    'class' => '类名称',
    'function' => '方法名称',
    'filename' => '钩子文件.php',
    'filepath' => 'hooks',
);
 */